package com.ccit.paas.controller;

import com.ccit.paas.rpc.dto.req.FlowRestApiAuthInfoAddReq;
import com.ccit.paas.rpc.dto.req.PageRequest;
import com.ccit.paas.rpc.dto.resp.FlowRestApiAuthInfoResp;
import com.ccit.paas.rpc.dto.resp.PageResult;
import com.ccit.paas.rpc.feign.FlowAuthFeignService;
import com.ccit.paas.rpc.vo.ResponseVO;
import com.ccit.wf.util.WorkFlowRepositoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/workflow/auth")
public class FlowAuthController {

    @Autowired
    private FlowAuthFeignService flowAuthFeignService;

    //@Autowired
    private WorkFlowRepositoryService workFlowRepositoryService;

/*
    @GetMapping("/test")
    void test() {
        System.out.println(workFlowRepositoryService);
    }
*/

    @PostMapping("/save")
    ResponseVO<Boolean> saveAuth(@RequestBody FlowRestApiAuthInfoAddReq req) {
        return flowAuthFeignService.saveAuth(req);
    }

    @PostMapping("/update")
    ResponseVO<Boolean> updateAuth(@RequestBody FlowRestApiAuthInfoAddReq req) {
        return flowAuthFeignService.updateAuth(req);
    }

    @GetMapping("/del")
    ResponseVO deleteAuth(@RequestParam String appId) {
        return flowAuthFeignService.deleteAuth(appId);
    }

    @PostMapping("/page")
    public ResponseVO<PageResult<FlowRestApiAuthInfoResp>> getPageList(@RequestBody PageRequest pageRequest) {
        return flowAuthFeignService.getWfFlowAuthPageList(pageRequest);
    }

    /**
     * say hello
     */
    @GetMapping("/all")
    String getAuthList() {
        return flowAuthFeignService.getAuthList();
    }
}
